package cn.openea.perpartner.evaluation.web.mapper;

import cn.openea.perpartner.evaluation.web.entity.EvaluationSignup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author rains
 * @since 2023-07-06 15:04
 */
public interface EvaluationSignupMapper extends BaseMapper<EvaluationSignup> {

    /**
     * 情况1：获取 评级开始时间前一天，尚未提交成果的 记录
     * @return
     */
    @Select("select * from meily_evaluation_signup where status = '待提交' HAVING datediff(end_time, DATE_FORMAT(now(), '%Y-%m-%d')) <= 1 ORDER BY end_time")
    List<EvaluationSignup> situationOne();

    /**
     * 情况2：获取 距离提交周期还有一天，尚未提交成果的 记录
     * @return
     */
    @Select("select * from meily_evaluation_signup where status = '待提交' and datediff(now(), DATE_ADD(create_time, INTERVAL submit_limit_days DAY)) <= 1 ORDER BY create_time")
    List<EvaluationSignup> situationTwo();

    /**
     * 情况3 获取距离报名截止时间还有3天，尚未提交成果的 记录
     * @return
     */
    @Select("select * from meily_evaluation_signup where status = '待提交' and datediff(join_end_time , now()) <= 3 ORDER BY create_time")
    List<EvaluationSignup> situationThree();

    /**
     * 获取需要回收超过限定天数未提交成果的任务
     * @return
     */
    @Select("select * from meily_evaluation_signup where status = '待提交' and  return_num = 0 and datediff(join_end_time , now()) <= 3 ORDER BY create_time")
    List<EvaluationSignup> getNeedToRecallSignupTask();
}
